//
//  AppDelegate.m
//  StarOrangeStaff
//
//  Created by lshenrong on 2020/6/17.
//  Copyright © 2020 lshenrong. All rights reserved.
//

#import "AppDelegate.h"
#import "YTKNetworkConfig.h"
#import "IQKeyboardManager.h"


@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    #if DEBUG
       CLog(@"width :%f  height: %f",SCREEN_WIDTH,SCREEN_HEIGHT);
       CLog(@"dir :%@",NSHomeDirectory());
    #endif
    [self appConfigure];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    [self showAppWindow];
    
    return YES;
}

- (void)showAppWindow {
    CedarTabBarController *tabVC = [[CedarTabBarController alloc] init];
    self.tabBarController = tabVC;
    self.window.rootViewController = tabVC;
    self.tabbarFrame = tabVC.tabBar.frame;
    
    #if DEBUG
    CLog(@"tabBar.frame %@",NSStringFromCGRect(tabVC.tabBar.frame));
    #endif
}

#pragma mark - configure

- (void)appConfigure{
    [IQKeyboardManager sharedManager].enable = YES;
    [self configureNavigationBar];
    [self configNetwork];
}
     
     
 - (void)configNetwork {
    [[YTKNetworkConfig sharedConfig] setBaseUrl:(NSString *)CedarBaseURL];
#if DEBUG
    [YTKNetworkConfig sharedConfig].debugLogEnabled = YES;
#endif
}

- (void)configureNavigationBar{
    UIFont *font = PingFangZhongChangGuiForFont(17);
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:kBlackColor,NSFontAttributeName:font}];
    [[UINavigationBar appearance] setTintColor:kBlackColor];
    [[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"back"]];
    [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"back"]];
    if(IOS_VERSION<11){
        [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -100) forBarMetrics:UIBarMetricsDefault];
    }
}

#pragma mark - UISceneSession lifecycle

//
//- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
//    // Called when a new scene session is being created.
//    // Use this method to select a configuration to create the new scene with.
//    return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
//}
//
//
//- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
//    // Called when the user discards a scene session.
//    // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
//    // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
//}


@end
